<?php

namespace App\Models;

use App\Traits\Relation\UserRelation;
use App\Traits\Authorization\Strategy;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;

/**
 * 用户数据模型
 *
 * Date: 19/03/2018
 * @author George
 * @property string $password
 * @property integer $company_id
 * @property string $registration_id
 * @method static find($id): User
 * @package App\Models
 */
class User extends Authenticatable implements JWTSubject
{
    use Notifiable, SoftDeletes, UserRelation, Strategy;

	/**
	 * 定义可批量填充字段
	 *
	 * @var array
	 * Date: 19/03/2018
	 * @author George
	 */
    protected $guarded = ['id'];

	/**
	 * 定义隐藏字段
	 *
	 * @var array
	 * Date: 19/03/2018
	 * @author George
	 */
    protected $hidden = [
        'password', 'created_at', 'updated_at', 'deleted_at'
    ];

	/**
	 * 定义属性类型转换
	 *
	 * @var array
	 * Date: 25/03/2018
	 * @author George
	 */
    protected $casts = [
    	'manager' => 'boolean'
	];

	/**
	 * 禁用RememberToken
	 *
	 * @var string
	 * Date: 19/03/2018
	 * @author George
	 */
    protected $rememberTokenName = '';

	/**
	 * 定义密码修改器
	 *
	 * Date: 2018/1/25
	 * @author George
	 * @param $value
	 */
	public function setPasswordAttribute($value)
	{
		$this->attributes['password'] = bcrypt($value);
	}

	/**
	 * 定义用于获取用户信息的主键
	 *
	 * @return mixed
	 */
	public function getJWTIdentifier()
	{
		return $this->getKey();
	}

	/**
	 * 自定义Payload内容
	 *
	 * @return array
	 */
	public function getJWTCustomClaims()
	{
		return [

        ];
	}
}
